package com.pay.ioopos.service;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;

import com.pay.ioopos.Application;
import com.pay.ioopos.receiver.PantReceiver;


public class PantService extends IntentService {
    private static boolean started = false;
    public PantService() {
        super("PantService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        if (started) return;
        started = true;
        startOnline();
    }

    private void startOnline() {
        try {
            do {
                online(true);
                Thread.sleep(3600000);// 1小时
            } while(true);
        } catch (InterruptedException ignored) {

        }
    }

    public static void online( boolean bool) {
        Intent receiver = new Intent(PantReceiver.class.getName());
        receiver.putExtra("online", bool);
        Application.getContext().sendBroadcast(receiver);
    }

}
